package com.cs.controller;

import com.cs.common.Result;
import com.cs.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * Created by IntelliJ IDEA.
 *
 * @author ouyangzhixiang
 * @date 2018/9/12
 */
@Controller
@RequestMapping("/user")
public class UserController {
    public UserController(UserService userService) {
        this.userService = userService;
    }

    private final UserService userService;

    @RequestMapping("/login")
    @ResponseBody
    public Result login(String username, String password) {
        return userService.login(username,password);
    }

    @RequestMapping("/select/{userId}")
    @ResponseBody
    public Result selectUser(@PathVariable("userId") Integer userId){
        return userService.selectUserByUserId(userId);
    }
}
